#ifndef __HWICODEC_SOC_COMMON_H__
#define __HWICODEC_SOC_COMMON_H__

#include <channel_vpu.h>

#define SOC_VPU_NAME    "/dev/soc_vpu"
#define MDELAY_TIME		(20000)
#define SOC_VDMA_SIZE	(0x5000)

#define HWICODEC_MIN_MB_WIDTH		(16)
#define HWICODEC_MIN_MB_HEIGHT	(1)

#define HWICODEC_TILE_MODE  0
#define HWICODEC_NV12_MODE  8
#define HWICODEC_NV21_MODE  12
#define HWICODEC_UNSUPPORT_MODE  -1

typedef struct hwicodec_soc_binfo {
	unsigned int	align;
	unsigned int	disalign;
	unsigned int	padh;
	unsigned int	padv;
	unsigned int	reserve_v;
	unsigned int	mbsize;
	unsigned int	interlaced;
	unsigned int	align_reserve;
	unsigned int	bufsize;
} hwicodec_soc_binfo_t;

typedef struct hwicodec_soc_bpool {
	int					buf_num;
	int					buf_size;
	intptr_t			buf_base_v;
	struct buf_info		binfo[C_CHN_NUM_MAX * C_VB_NUM_MAX];
	int					vb_num;
	hwicodec_vbinfo_t		vbinfo[C_VB_NUM_MAX];
} hwicodec_soc_bpool_t;

typedef struct hwicodec_soc_chn {
	struct channel_node	cnode;
	void				*p;		/* should be init dma paramters */
	void				*c;		/* should be init ncu paramters */
} hwicodec_chn_t;

typedef struct hwicodec_soc_cnpool {
	int					cn_num;
	hwicodec_chn_t		chn[C_CHN_NUM_MAX];
} hwicodec_soc_cnpool_t;

typedef struct hwicodec_plane_info {
	hwicodec_plane_t		p;
	hwicodec_plane_size_t	s;
} hwicodec_plane_info_t;

typedef struct hwicodec_plane_pool {
	int					num;
	hwicodec_plane_info_t	elem[C_VB_NUM_MAX];
} hwicodec_plane_pool_t;

typedef struct hwicodec_soc {
	int					fd;
	int					vpu_num;
	hwicodec_soc_bpool_t	bpool;
	hwicodec_soc_cnpool_t cnpool;
	hwicodec_plane_pool_t ppool;
} hwicodec_soc_t;

extern int hwicodec_tlb(hwicodec_t *h, intptr_t vaddr, int size, int ch);
extern int hwicodec_vb_tlb(hwicodec_t *h, hwicodec_plane_pool_t *ppool, hwicodec_plane_t *pplane,
		hwicodec_plane_size_t *psize, int ch);
extern void hwicodec_pf_deinit_bpool(hwicodec_t *h);
extern inline int convert_csp_to_vpu_mode(int i_csp);
extern int hwicodec_pf_request_vbinfo(hwicodec_t *h, hwicodec_vbinfo_t **vbinfo, int *vbnum);
extern void hwicodec_pf_release_vbinfo(hwicodec_t *h, hwicodec_vbinfo_t *vbinfo);

#endif /* __HWICODEC_SOC_COMMON_H__ */
